package com.hongdee.crm.workorder.controller;

import com.hongdee.crm.task.service.ICarBaseCountService;
import com.hongdee.crm.workorder.service.ITCrmCarWorkOrderQueryService;
import com.hongdee.crm.workorder.service.impl.TCrmCarWorkOrderQueryServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2017/7/18 0018.
 */
@RestController
@RequestMapping("/crm/workorderquery")
public class TCrmCarWorkOrderQueryController {
    @Autowired
    private ITCrmCarWorkOrderQueryService iTCrmCarWorkOrderQueryService;
    @RequestMapping("/page")
    @ResponseBody
    public Map workerOrderQuery(@RequestParam(name = "uid", defaultValue = "") String uid,
                                @RequestParam(name = "token", defaultValue = "") String token,
                                @RequestParam(name = "orderNum", defaultValue = "") String orderNum,
                                 @RequestParam(name = "platenum", defaultValue = "") String platenum,
                                 @RequestParam(name = "start", defaultValue = "0") String start,
                                 @RequestParam(name = "limit", defaultValue = "50") String limit,
                                 @RequestParam(name = "vin", defaultValue = "") String vin,
                                 @RequestParam(name = "balanceDateStart", defaultValue = "") String balanceDateStart,
                                @RequestParam(name = "balanceDateEnd", defaultValue = "") String balanceDateEnd,
                                @RequestParam(name = "companyId", defaultValue = "") String companyId) throws Exception{
        Map map = this.iTCrmCarWorkOrderQueryService.impPage(companyId,orderNum, start, limit, platenum, vin, balanceDateStart,balanceDateEnd,uid);
        map.put("success", true);
        map.put("msg", "查询成功！");

        return map;
    }

    @RequestMapping("/table")
    public Map workOrderTable(@RequestParam(name = "uid", defaultValue = "") String uid,
                              @RequestParam(name = "token", defaultValue = "") String token,
                              @RequestParam(name = "start", defaultValue = "0") String start,
                              @RequestParam(name = "limit", defaultValue = "50") String limit,
                              @RequestBody Map data) throws Exception{
        String maintainer = (String) data.get("maintainer");
        String plateNumber = (String) data.get("licensePlateNamber");
        String maintainDate = (String) data.get("maintainDate");
        String dateStart = (String) data.get("dateStart");
        String dateStop = (String) data.get("dateStop");

        Map map = this.iTCrmCarWorkOrderQueryService.workOrderTable(uid,maintainer,maintainDate,plateNumber,start,limit,dateStart,dateStop);
        map.put("success",true);
        map.put("msg","查询成功！");
        return map;
    }
}
